PG:SimpleUpdate
Bezeichnung |
PG:SimpleUpdate -- Führt ein Update, eine Änderung in der Datenbank aus.
Übersicht |
Fail, ErrorCode = PG:SimpleUpdate(SQL$, ConnectionID)
Beschreibung |
PG:SimpleUpdate kann nur Aktionen wie etwa "DROP TABLE" oder "CREATE TABLE" in der Datenbank ausführen. Es ist nicht möglich damit Daten zu lesen.
Für Abfragen wie "SELECT" benutzen Sie bitte PG:SimpleQuery oder PG:ExtendedQuery.
Eingaben |
SQL$
Dieser String muss die SQL-Abfrage enthalten.
ConnectionID
ID der Netzwerkverbindung
Rückgabewerte |
Fail
True wenn ein Fehler aufgetreten ist.
False wenn alles funktioniert hat.
ErrorCode
Einen dreistelligen internen Fehlercode oder einen fünfstelligen PostgreSQL Fehlercode.
Ansonsten False.
Beispiel |
Dieser Code erstellt folgende Tabelle:
- Tabellen-Name: Kunde
- Die Spalte "vorname" vom Typ "text"
- Die Spalte "name" vom Typ "text"
/**************************************************************** ** ** ** Name: 2_DBUpdate_CreateTable ** ** Author: Michael Suther ** ** Date: 01.05.19 ** ** Interpreter: Hollywood 8.0 ** ** Function: Creates a new table in a PgSQL DB ** ** ** ** ** ****************************************************************/ @INCLUDE "PostgreSQL_Lib.hws" Block Local Fail, ConnectionID, SQL$ Local Errorcode Local Host$ = "localhost" Local Port = 5432 Local Database$ = "postgres" Local Username$ = "test" Local Passwort$ = "test"
;registration Fail, ErrorCode, ConnectionID = PG:OpenDatabase(Host$, Port, Database$, Username$, Passwort$)
; Evaluating the Return values If Fail = False NPrint("Connection was successfully established.") Else NPrint("") NPrint("The connection failed.") NPrint("") NPrint("Error code: ", ErrorCode) WaitLeftMouse End EndIf ;The SQL query Local SQL$ = "CREATE TABLE Kunde (vorname text, name text)"
;Create a new table Fail, Errorcode = PG:SimpleUpdate(SQL$, ConnectionID)
; Evaluating the Return values If Fail = False NPrint("") NPrint("Table was created.") Else NPrint("") NPrint("Create Table failed.") NPrint("") NPrint("Error code: ", ErrorCode) EndIf
WaitLeftMouse
;Close connection To the database. PG:CloseDatabase(ConnectionID) End EndBlock |
Mit dem Personal Edition von HelpNDoc erstellt: Funktionsreicher Hilfegenerator